<?php 
/**
 * 商品详细表管理模型
 */
class GoodsDetailsModel extends Model{
    public $table = 'goods_details';
    
    public $auto = array();
    
    public $validate = array(
		array('introduce','nonull','商品详细内容不能为空',1,3),
	);
	/**
	 * 添加
	 */
	public function addDetails($gid,$big){
		
		$this->data['big']=$big;
		$img = new Image();
//		组合小图图片名字与路径
		$imgFiles='Static/Goods/small_'.basename($big);
		
		$this->data['small']=$img->thumb($big,$imgFiles,69,69,5);
		$this->data['gid']=$gid;
		$this->add();
	}   
	/**
	 * 编辑
	 */ 
	public function editDetails($gid,$big){
		$oldBig=$this->where("gid={$gid}")->find();
//		如果上传图片
		if($big!=$oldBig['big']){
			$img = new Image();
	//		组合小图图片名字与路径
			$imgFiles='Static/Goods/small_'.basename($big);
			
			$this->data['small']=$img->thumb($big,$imgFiles,69,69,5);	
		}
		$this->data['big']=$big;
//		判断提交过来的商品详细是否有内容（没有给一个空字符串）
		$this->data['introduce']=isset($_POST['introduce'])?$_POST['introduce']:'';
		$this->where("gid={$gid}")->update();
	}
    
 }
 
 
 
 
 
 
 
 
 
 
 







 ?>